package utils

import (
	"crypto/md5"
	"encoding/hex"
)

// MD5
func EncodeMd5(data string) string {
	h := md5.New()
	h.Write([]byte(data))
	tempString := h.Sum(nil)

	return hex.EncodeToString(tempString)
}

// 对密码加密
func Md5Password(password, salt string) string {
	return EncodeMd5(password + salt)
}

// 解密
func ParserPassword(password, salt, dbPassword string) bool {
	return dbPassword == Md5Password(password, salt)
}
